<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Homework Day1</title>
    <style>
        :root {
            --text-origin-color: black;
            --text-effect-color: red;
            --turn-color-text: "变为红色";
        }

        body {
            font-family: monospace;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .con {
            width: 350px;
            margin-top: 200px;
            text-align: center;
        }

        #text {
            position: relative;
            width: 100%;
            font-size: 50px;
            font-weight: bold;
            margin-bottom: 100px;
            color: var(--text-origin-color);
        }

        #cover-text {
            position: absolute;
            width: 100%;
            top: 0;
            left: 0;    
            color: var(--text-effect-color);
            transition: 1s ease;
            clip-path: circle(0px);      
        }

        .effect-text {
            clip-path: circle(200px) !important;
        }

        .btn-box {
            width: 100%;
            display: flex;
            justify-content: space-around;
            align-items: center;
        }

        button {
            position: relative;
            background: none;
            width: 150px;
            height: 50px;
            border: 4px solid;
            font-size: 18px;
        }

        button::before,
        button::after {
            content: '';
            position: absolute;
            width: 8px;
            height: 4px;
            background-color: white;
            transform: skew(-50deg);
            transition: .4s linear;
        }

        button::before {
            top: -4px;
            left: 20%;
        }

        button::after {
            bottom: -4px;
            right: 20%;
        }

        button:hover::before {
            left: 80%;
        }

        button:hover::after {
            right: 80%;
        }

        #turn-color {
            /* position: relative; */
            color: var(--text-effect-color);
            border-color: var(--text-effect-color);
        }
        #turn-color-text {
            display: flex;
            justify-content: center;
            align-items: center;
            position: absolute;
            top: 0;
            left: 0;
            z-index: -1;
            width: 100%;
            height: 100%;
        }
        #turn-color-text::before {
            content: var(--turn-color-text);
        }
    </style>
</head>
<body>
    <div class="con">
        <div id="text">
            Hello World!
            <div id="cover-text">
                Hello World!
            </div>
        </div>
        <div class="btn-box">
            <button id="turn-color"><span id="turn-color-text"></span></button>
            <button id="reset">复原</button>
        </div>
    </div>


    <script>
        let coverText = document.getElementById('cover-text');
        let redBtn = document.getElementById('turn-color');
        let reset = document.getElementById('reset');

        redBtn.addEventListener('click', () => {
            coverText.classList.add('effect-text');
        })

        reset.addEventListener('click', () => {
            coverText.classList.remove('effect-text');
        })
    </script>
</body>
</html>